#ifndef CHARACTERS_H
#define CHARACTERS_H

// Libraries
#include "state.h"
#include "singleton.h"

// Constants
const int CHARACTERS_MAX = 6;

// Forward Declarations
class PacketClass;

// Structures
struct SlotStruct {
	IGUIButton *Button;
	stringc Name;
	int Level;
	bool Used;
};

// Classes
class CharactersState : public CState, public Singleton<CharactersState>
{
	public:
		enum ElementType 
		{
			ELEMENT_PLAY,
			ELEMENT_LOGOUT,
			ELEMENT_CREATE,
			ELEMENT_DELETE,
			ELEMENT_DELETECONFIRM,
			ELEMENT_SLOT0,
			ELEMENT_SLOT1,
			ELEMENT_SLOT2,
			ELEMENT_SLOT3,
			ELEMENT_SLOT4,
			ELEMENT_SLOT5,
		};

		bool Show();
		bool Hide();
		
		void HandleDisconnect(ENetEvent *TEvent);
		void HandlePacket(ENetEvent *TEvent);
		bool HandleKeyPress(EKEY_CODE TKey);
		void HandleGUI(EGUI_EVENT_TYPE TEventType, IGUIElement *TElement);

		void Update(u32 TDeltaTime);
		void Draw();

	private:

		void HandleCharacterList(PacketClass *TPacket);
		void UpdateSelection(int TSelectedIndex);
		void RequestCharacterList();
		void PlayCharacter();
		void Delete();
		void Logout();

		// GUI
		IGUIButton *ButtonPlay, *ButtonLogout, *ButtonCreate, *ButtonDelete;
		SlotStruct Slots[CHARACTERS_MAX];
		int SelectedIndex;
		u32 ClickTimer;
		
};

#endif
